<?php
error_reporting(0);
include_once '../comm/config.php';
include_once '../comm/checkpostandget.php';
include_once '../comm/class.phpmailer.php';
include_once '../comm/wjt.php';
$tag="center";
$mymsg= "邮件发送失败！可能是邮件服务器设置错误，请联系网站管理员!";
$email=trim($_POST['email']); 

//检查用户名是否被注册
$q = "SELECT * FROM `".$BIAOTOU."user` where email='".$email."' limit 1";
$rs = mysql_query($q);
$row = mysql_fetch_object($rs);
if($row->ddusername=='')
{
	header('Location: error.php?id=17');
	exit;
}
else
{
	$ddusername=$row->ddusername; 
	$ddpassword=$row->ddpassword; 
	$email=$row->email; 
	$x = md5($ddusername.'+'.$ddpassword);
	$string = base64_encode($ddusername."*".$x.'*'.time());
	if(SMTPOPEN=='on'){				
		$html="请点击链接进入".WEBTITLE."进行密码重置。有效时间10分钟。<a href=\"http://".URL."/user/getpassword_step3.php?str=".urlencode($string)."\">http://".URL."/user/getpassword_step3.php?str=".urlencode($string)."</a>";
		$from=SMTPUSER;//发送邮箱 例如：123@sina.com
		$fromname=SMTPUSER;//邮件姓名、例如张三
		$to=$email;//发到哪个邮箱，就是收信邮箱例如:456@sina.com
		$title=WEBTITLE."取回密码邮件";//邮件标题
		$usename=SMTPUSER;//登陆发送邮箱的登录名 如果$from设置为123@sina.com，则$usename=123
		$usepassword=SMTPPW;//登陆发送邮箱的密码：就是123@sina.com的登陆密码
		$smtp=SMTPHOST;//邮件服务器地址
		$mymsg=mail_send($to, $title, $html);
	}
}     
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>找回密码 - 用户中心</title>
<link href="../css/usercss.css" rel="stylesheet" type="text/css">
<link href="../template/<?=MOBAN?>/css/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body>
<?php
include("../template/".MOBAN."/header.tpl.php");
?>
<?php
include("../template/".MOBAN."/nav.tpl.php");
?> 
<div id="maincenter">
  <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="50" align="left">&nbsp;</td>
  </tr>
  <tr>
    <td height="50" align="center"><img src="../images/step2.gif" alt="找回密码第二步" width="637" height="31" /></td>
  </tr>
  <tr>
    <td height="50" align="center"></td>
  </tr>
  <tr>
    <td height="50" align="center" style="font-size:14px"><?=$mymsg?></td>
  </tr>
</table>
</div>
<?php
include("../template/".MOBAN."/footer.tpl.php");
mysql_close();
?>
</body>
</html>